﻿@{int i = 0;}@inherits  BuildCodeViewPage<TableInfo>
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using Bigger.DataBase;
using Bigger.DataBase.ORM;
using Bigger.DataBase.Valid;
using Bigger.DataBase.Metadata;

namespace @(Model.Namespace).Models
{
    /// <summary>
    /// @Model.Description
    /// </summary>
    [Serializable]
    [DataSource(Name = "@Model.TableName")]
    public class @Model.Name : ModelBase
    {
        #region Public Properties
@foreach (var columnInfo in Model.ColumnInfos)
{
        <tj>/// <summary>
        /// @columnInfo.Description
        /// </summary>
    @if(i==0)
    {
        <tj>[PrimaryKey]</tj>
    }
        <tj>[Description("@columnInfo.Description")]</tj>
@if (CurrentBuilder.IsString(columnInfo.DataType))
{
    if (!columnInfo.IsNull)
    {
        <tj>[Required]</tj>
    }
    if (Convert.ToString(columnInfo.Datalength) != "-1")
    {
        <tj>[StringLength(MinimumLength = 0, MaximumLength = @(columnInfo.Datalength))]</tj>
    }
}
        public @CurrentBuilder.GetNoticeType(columnInfo.DataType, columnInfo.IsNull) @columnInfo.Name.ToFirstUpper() { get; set; }</tj>
        i++;
}
        #endregion

        #region Construction
        /// <summary>
        /// 构造函数
        /// </summary>
        public @(Model.Name)()
        {
@{
    foreach (var columnInfo in Model.ColumnInfos.Skip(1))
    {
        if (columnInfo.IsNull)
        {
            <tj>this.@(columnInfo.Name.ToFirstUpper()) = @CurrentBuilder.SetDbNullValue(CurrentBuilder.GetNoticeType(columnInfo.DataType));</tj>
        }
        else
        {
            <tj>this.@(columnInfo.Name.ToFirstUpper()) = @CurrentBuilder.SetDefaultValue(CurrentBuilder.GetNoticeType(columnInfo.DataType));</tj>
        }
    }
}
        }
        #endregion
    }
}